﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Dynamic.Core;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Domain.Repositories;
using Volo.Abp.ObjectMapping;

namespace Himp.Platform
{
    public class MenuTreeService : PlatformAppService
    {
        private IRepository<Menu, Guid> _menuRepository;

        public MenuTreeService(IRepository<Menu, Guid> MenuRepository)
        {
            _menuRepository = MenuRepository;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task<List<MenuDto>> GetListAsync(MenuInput input)
        {
            List<MenuDto> systemMenuDtos = new List<MenuDto>();
            var iQuery = await _menuRepository.WithDetailsAsync();
            var menus = iQuery.ToList();
            menus = menus.Where(i => i.ParentId == null).ToList();
            var itemsDto = ObjectMapper.Map<List<Menu>, List<MenuDto>>(menus);

            return systemMenuDtos;
        }
    }
}
